{extend name="layout/layout"}
{block name="content"}
<main class="user_page active ufm_page">
    <section class="">
        <div class="layui-main">
            <div class="user_con">
                <div class="user_headpage" data-load="user_files_header">
                    {include file="user_activity/page_user" menu='info' /}
                </div>
                <div class="right_main block1">
                    <p class="t18 mb40">關於我</p>
                    <p class="ft15 ft-bold mb50">個人大頭貼</p>
                    <from class="layui-form">
                        <div class=" flex-center mb50">
                           <div class="user_upload">
                              {if $user.profile != ''}
                                <div class="user_img">
                                    <img src="{$user.profile}" id="upload-img">
                                </div>
                                {else /}
                                <div id="upload-btn" class="btn">
                                    <img class="layui-circle" src="__ROOT__/public/activity/images/upload.png">
                                 </div>
                              {/if}
                           </div>
                           <input type="hidden" class="profile" name="profile">
                        </div>
                        <div class="layui-form-item">
                           <div class="label must">顯示名稱</div>
                           <div class="">
                              <input type="text" name="nickname" value="{$user.nickname}" lay-verify="required" placeholder="你希望怎么被称呼"
                                 autocomplete="off" class="layui-input">
                           </div>
                        </div>
                        <div class="layui-form-item">
                           <div class="label ">目前 Email</div>
                           <div class="">
                              <p class="gary_c9 ft14">{$user.email}</p>
                           </div>
                        </div>
                        <div class="layui-form-item">
                           <div class="label must">姓名</div>
                           <div class="">
                              <input type="text" name="name" value="{$user.name}" lay-verify="required" placeholder="" autocomplete="off"
                                 class="layui-input">
                           </div>
                        </div>
                        <div class="layui-form-item">
                           <div class="label must">生日</div>
                           <div class="">
                              <input id="datetime-1" type="text" name="birth" value="{$user.birth}" lay-verify="required" placeholder=""
                                 autocomplete="off" class="layui-input">
   
                           </div>
                        </div>
                        <div class="layui-form-item">
                           <div class="label ">性別</div>
                           <div class="">
                              <select name="gender" lay-filter="aihao">
                                 <option {$user.gender == 0 ? 'selected' : ''}  value="0">保密</option>
                                 <option {$user.gender == 1 ? 'selected' : ''}  value="1">男</option>
                                 <option {$user.gender == 2 ? 'selected' : ''}  value="2">女</option>
                              </select>
                           </div>
                        </div>
                        <div class="layui-form-item">
                           <div class="label ">感情狀態</div>
                           <div class="">
                              <select name="emotional" lay-filter="aihao">
                                 <option {$user.emotional == 0 ? 'selected' : ''} value="0">保密</option>
                                 <option {$user.emotional == 1 ? 'selected' : ''} value="1">已婚</option>
                                 <option {$user.emotional == 2 ? 'selected' : ''} value="2">未婚</option>
                                 <option {$user.emotional == 3 ? 'selected' : ''} value="3">离异</option>
                              </select>
                           </div>
                        </div>
                        <div class="layui-form-item">
                           <div class="label ">手機號碼</div>
                           <div class="">
                              <input type="text" name="phone" lay-verify="required"  value="{$user.phone}" placeholder="" autocomplete="off"
                                 class="layui-input">
                           </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="label">現居地</p>
                            </div>
                            <div class="">
                                <input type="text" name="address" lay-verify="required"  value="{$user.address}" placeholder="" autocomplete="off"
                                   class="layui-input">
                             </div>
                            <!-- <div class="">
                                <div class="mb12">
                                    <lay-tree-select v-model="form.region_id" :data="region" placeholder="请选择活动地点"></lay-tree-select>
                                </div>
                                <lay-input placeholder="请填写详细地址"  v-model="form.address_detail"></lay-input>
                            </div> -->
                        </div>
                        <div class="layui-form-item">
                           <!-- <button class="layui-btn layui-btn-lg layui-btn-primary layui-border">放弃更改</button> -->
                           <button class="layui-btn layui-btn-lg layui-bg-orange" lay-submit lay-filter="formDemo">保存</button>
                        </div>
                     </from>
                </div>
            </div>
        </div>
    </section>
</main>
<script>
    
    layui.use(function () {
        var upload = layui.upload;
        var layer = layui.layer;
        var element = layui.element;
        var $ = layui.$;
        var laydate = layui.laydate;
        var form = layui.form
          //提交
        form.on('submit(formDemo)', function(data){
            // layer.msg(JSON.stringify(data.field));
            $.quickPost('/activity/user/info', data.field).done(function(){

            })
            return false;
        });
          
        //执行一个laydate实例
        laydate.render({
            elem: '#datetime-1' //指定元素
        });
        // 单图片上传
        var uploadInst = upload.render({
            elem: '#upload-img',
            url: '/api/upload', // 实际使用时改成您自己的上传接口即可。
            before: function (obj) {
                // 预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#upload-img').attr('src', result); // 图片链接（base64）
                });
            },
            done:function (res){
                if(res.code===1){
                    $('.profile').val(res.data.url);
                }
            }

        });
    })
    function saveChange(){
        var data = layui.form.val('user-info-form');
        $.quickPost('/activity/user/info',data)
    }
</script>
{/block}